package com.spi.soconversion.base.definition;

import com.spi.soconversion.util.SOCConstants;
import com.spi.soconversion.util.SOCUtility;
import com.spi.soconversion.util.XMLAttributeConstants;
import com.spi.soconversion.util.XMLTagConstants;

public class SOCOrderNote {

	
		private String noteText;
		private String notePriority=SOCConstants.ZERO;
		private String reasonCode;
		
		public String getNoteText() {			
			this.noteText= SOCUtility.checkNull(noteText);
			if(noteText.length()>2000)
			{
				noteText = noteText.substring(0, 2000);
			}
			return noteText;
		}

		public void setNoteText(String noteText) {
			this.noteText = noteText;
		}
		
		public String getNotePriority() {
			return notePriority;
		}
		
		public void setReasonCode(String reasonCode) {
			this.reasonCode = reasonCode;
		}

		public String getReasonCode() {
			return SOCUtility.checkNull(reasonCode);
		}
		
		@Override
		public String toString() {
			StringBuilder sb = new StringBuilder();

			sb.append(XMLTagConstants.START_TAG_NOTE);
			sb.append(SOCConstants.BLANK_STRING);
			
			sb.append(SOCUtility.getAttribute(XMLAttributeConstants.NOTE_TEXT,
					SOCUtility.replaceXMLSpecialCharacters(getNoteText())));
			sb.append(SOCConstants.BLANK_STRING);
			
			sb.append(SOCUtility.getAttribute(
					XMLAttributeConstants.NOTE_PRIORITY, getNotePriority()));
			sb.append(SOCConstants.BLANK_STRING);
			
			sb.append(SOCUtility.getAttribute(
					XMLAttributeConstants.NOTE_REASON_CODE, getReasonCode()));
			sb.append(SOCConstants.BLANK_STRING);

			sb.append(SOCConstants.CLOSING_XML_TAG);
			sb.append(SOCConstants.NEW_LINE);

			sb.append(XMLTagConstants.END_TAG_NOTE);

			return sb.toString();
		}
		
}
